package com.zjsru.payment.mapper;

import com.zjsru.payment.pojo.ProductTransaction;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PaymentMapper {

    @Insert("insert into product_transaction(user_id,product_id,transaction_amount,create_time,update_time) values(#{userId},#{productId},#{transactionAmount},now(),now())")
    void createTransaction(ProductTransaction productTransaction);

    @Select("select * from product_transaction")
    List<ProductTransaction> queryTransaction();

    @Select("select * from product_transaction where user_id = #{userId}")
    List<ProductTransaction> queryTransactionByUserId(Long userId);

    @Select("select * from product_transaction where transaction_id = #{transactionId}")
    ProductTransaction queryTransactionById(Long transactionId);

    @Delete("delete from product_transaction where transaction_id = #{transactionId}")
    void refund(Long transactionId);
}
